package org.come.control;
import java.util.Map;
import org.come.action.FromServerAction;
import org.come.bean.AllNpcBean;
import org.come.bean.NpcInfoBean;
import org.come.model.Gamemap;
import org.come.socket.DownLoadTxt;
import org.come.until.DataUtil;
import org.come.until.UserMessUntil;
import com.tool.image.ImageMixDeal;
import com.tool.role.RoleData;

/**
 * 更新表格
 * @author Administrator
 *
 */
public class UpdateTextControl implements FromServerAction {
    public static String message;
    public static String url;
    @Override
    public void controlMessFromServer(String mes,String type) {
        System.out.println("mes:" + mes);
        if(mes.contains("下载url")) {
        	System.out.println(mes);
        }else 
        if(mes.contains("全服三倍")) {
        }else {
        	message = mes.replace(".xls", ".txt");
        	Thread thread = new Thread(new Runnable() {
        		@Override
        		public void run() {
        			
        			if(message.equals("npc.txt") || message.equals("map.txt")) {//祝福树
        				DownLoadTxt.getDownLoadTxt().initMes(message);
        				AllNpcBean allNpcBean = UserMessUntil.getAllNpcBean();
        				if(DataUtil.isNotEmpty(allNpcBean)) {
        					Map<String, NpcInfoBean> npcs = allNpcBean.getAllNpcInfo();
        					NpcInfoBean npctable = npcs.get(999+""+RoleData.getRoleData().getLoginResult().getRole_id());
        					if(DataUtil.isNotEmpty(npctable) && DataUtil.isNotEmpty(npctable.getNpctable()) && DataUtil.isNotEmpty(npctable.getNpctable().getNum())) {
        						if(message.equals("npc.txt")) {
        							System.err.println("浇水=="+npctable.getNpctable().getNum());
        						}
        						if(message.equals("map.txt")) {
        							Gamemap gamemap = UserMessUntil.getAllmapbean().getAllMap().get(RoleData.getRoleData().getLoginResult().getMapid() + "");
        							if(RoleData.getRoleData().getLoginResult().getMapid() == 1193) {
        								ImageMixDeal.NpcLoad(gamemap.getMapnpc());
        							}
        						}
        					}
        				}
					}
        			DownLoadTxt.getDownLoadTxt().initMes(message);
        		}
        	});
        	thread.start();
        }
    }
}
